var mysql = require('mysql');
var connection = mysql.createConnection({
    host: '101.33.240.49',
    user: 'xuan',
    password: '123456',
    database: 'todolist'
});
connection.connect((err) => {
    if (err) {
        throw err;
    }
    console.log('mysql 连接成功');
});


let query = (sql, params) => {
    return new Promise((resolve, reject) => {
        connection.query(sql, params, (error, result, fields) => {
            if (error) {
                reject(error);
            } else {
                resolve(result);
            }
        })
    })
}

module.exports = { connection, query };